package com.minimalist.lindi.controller;

import com.minimalist.common.config.mybatis.bo.PageResp;
import com.minimalist.common.entity.lindi.vo.enterpriseregistration.LindiEnterpriseRegistrationAuditVO;
import com.minimalist.common.entity.lindi.vo.enterpriseregistration.LindiEnterpriseRegistrationQueryVO;
import com.minimalist.common.entity.lindi.vo.enterpriseregistration.LindiEnterpriseRegistrationVO;
import com.minimalist.common.response.R;
import com.minimalist.common.utils.Add;
import com.minimalist.common.utils.Update;
import com.minimalist.lindi.service.LindiEnterpriseRegistrationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author 11987
 */
@Validated
@RestController
@Tag(name = "林地指标交易平台_企业注册管理")
@RequestMapping("/lindi/enterpriseRegistration")
public class LindiEnterpriseRegistrationController{

    @Autowired
    private LindiEnterpriseRegistrationService service;

    @PostMapping("/addEnterpriseRegistration")
    @Operation(summary = "添加企业注册信息")
    public R<Void> addEnterpriseRegistration(
            @RequestBody @Validated(Add.class)
            LindiEnterpriseRegistrationVO enterpriseRegistrationVO){
        service.addEnterpriseRegistration(enterpriseRegistrationVO);
        return R.ok();
    }

    @DeleteMapping("/deleteEnterpriseRegistrationByEnterpriseRegistrationId")
    @Operation(summary = "删除企业注册信息 -> 根据企业注册信息ID删除")
    public R<Void> deleteEnterpriseRegistrationByEnterpriseRegistrationId(
            @RequestParam("enterpriseRegistrationId")
            @NotNull(message = "企业注册信息ID不能为空")
            @Parameter(name = "enterpriseRegistrationId", required = true
                    , description = "企业注册信息ID") Long enterpriseRegistrationId){
        service.deleteEnterpriseRegistrationByEnterpriseRegistrationId
                (enterpriseRegistrationId);
        return R.ok();
    }

    @PutMapping("/updateEnterpriseRegistrationByEnterpriseRegistrationId")
    @Operation(summary = "修改企业注册信息")
    public R<Void> updateEnterpriseRegistrationByEnterpriseRegistrationId(
            @RequestBody @Validated(Update.class)
            LindiEnterpriseRegistrationVO enterpriseRegistrationVO){
        service.updateEnterpriseRegistrationByEnterpriseRegistrationId
                (enterpriseRegistrationVO);
        return R.ok();
    }

    @GetMapping("/getPageEnterpriseRegistrationList")
    @Operation(summary = "查询企业注册信息列表(分页)")
    public R<PageResp<LindiEnterpriseRegistrationVO>>
    getPageEnterpriseRegistrationList(
            @RequestBody LindiEnterpriseRegistrationQueryVO queryVO){
        return R.ok(service.getPageEnterpriseRegistrationList
                (queryVO));
    }

    @GetMapping("/getEnterpriseRegistrationByEnterpriseRegistrationId/{enterpriseRegistrationId}")
    @Operation(summary = "根据企业注册信息ID查询企业注册信息")
    public R<LindiEnterpriseRegistrationVO> getEnterpriseRegistrationByEnterpriseRegistrationId(
            @PathVariable(value = "enterpriseRegistrationId")
            @NotNull(message = "企业注册信息ID不能为空")
            @Parameter(name = "enterpriseRegistrationId", description = "参数ID"
                    , required = true) Long enterpriseRegistrationId){
        return R.ok(
                service.getEnterpriseRegistrationByEnterpriseRegistrationId
                        (enterpriseRegistrationId));
    }

    @PostMapping("/auditEnterpriseRegistration")
    @Operation(summary = "审核企业注册信息")
    public R<Void> auditEnterpriseRegistration(
            @RequestBody @Validated(Update.class)
            LindiEnterpriseRegistrationAuditVO auditVO){
        service.auditEnterpriseRegistration(auditVO);
        return R.ok();
    }
}